package wangjg.sso.util;

import java.util.Date;

import net.sf.ezmorph.ObjectMorpher;

public class MyDateMorpher implements ObjectMorpher{

	private String[] formats;
	
	@Override
	   public Object morph( Object value )
	   {
	      if( value == null ){
	         return null;
	      }
	      if( Date.class.isAssignableFrom( value.getClass() ) ){
	         return (Date) value;
	      }
	      if( Long.class.isAssignableFrom( value.getClass() ) ){
		         return new Date((Long) value);
		  }
	      if( long.class.isAssignableFrom( value.getClass() ) ){
		         return new Date((Long) value);
		  }
	      return null;
	}

	@Override
	public Class morphsTo() {
		return Date.class;
	}
	@Override
	public boolean supports(Class clazz) {
		return Long.class.isAssignableFrom(clazz)||String.class.equals(clazz);
	}
	
}